package com.humngyang.com.hmy.controller;


import com.humngyang.com.hmy.entity.User;
import com.humngyang.com.hmy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/UserController")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/getUserOne")
    public Map getUserOne(@RequestBody User user) {
        Map<String, Object> userOne = userService.getUserOne(user);
        return userOne;
    }

    @RequestMapping("/getUserList")
    public Map<String, Object> getUserList(@RequestBody Map<String, Object> prames) {
        Map<String, Object> userList = userService.getUserListPage(prames);
        return userList;
    }


    @RequestMapping("/addOrUpdateUser")
    public Map<String, Object> addOrUpdateUser(@RequestBody User user) {
        Map<String, Object> map = userService.addOrUpdateUser(user);
        return map;
    }

    /**
     * Author : hmy
     * @date 2020/2/23 16:28
     * describution :
     **/
    @RequestMapping("/getUserById")
    public Map<String, Object> getUserById(@RequestBody User user) {
        Map<String, Object> map = userService.getUserById(user.getId());
        return map;
    }

    /**
     * Author : hmy
     * @date 2020/2/23 20:38
     * describution : 根据id删除用户信息
     **/

    @RequestMapping("/deleteUserById")
    public Map<String, Object> deleteUserById(@RequestBody User user) {
        Map<String, Object> map = userService.deleteUserById(user.getId());
        return map;
    }


}
